<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="model.*"%>
<%@ page import="dao.*"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	String user = (String) session.getAttribute("user");
	if (user != null && user.equals("1")) {

	} else {
		response.sendRedirect("Login.jsp");
	}
%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	List<Tourist> tourists = new ArrayList<Tourist>();
	tourists = TouristDao.getTourists();
	for (Tourist item : tourists) {
	}
	request.setAttribute("tourists", tourists);
%>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8" />
<title>管理订单信息</title>
<style>
.table{
table-layout: fixed;
}
</style>

<jsp:include page="Header.jsp" flush="true"></jsp:include>


<!-- Latest Products -->
<div id="订单">

	<div class="content-lg container">
		<div class="row margin-b-40">
			<div class="col-sm-6">
				<h2>管理订单信息</h2>
				<br>

			</div>
			<div class="col-sm-6"></div>
		</div>
		<!--// end row -->

		<div class="row">

			<c:forEach var="tourist" items="${tourists}" varStatus="status">

				<div class="row margin-b-10">
					<div class="col-sm-6">
						<h3>游客名称:${tourist.name }</h3>
					</div>
					<div class="col-sm-6">

						<p></p>
					</div>

				</div>



				<table class="table table-bordered mtable2" width="100%"
					cellspacing="0">
					<thead>
						<tr>
							<th>序号</th>
							<th>订单名称</th>
							<th>价格</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>

					<tbody>


						<c:forEach var="horder" items="${tourist.getHorders()}"
							varStatus="status">
							<c:choose>
								<c:when test="${horder.status=='0'}">
									<c:set value="未交费" var="fg" />

								</c:when>
								<c:otherwise>
									<c:set value="交费" var="fg" />

								</c:otherwise>
							</c:choose>
							<tr>
								<td>${status.index +1}</td>
								<td>${horder.getHotel().name }</td>
								<td>${horder.getHotel().price }</td>
								<td>${fg }</td>
								<td><a
									href="javascript:if(confirm('确定要交费吗?'))location='<%=request.getContextPath()%>/HorderStatusServlet?temail=${horder.getId().getTEmail() }&hemail=${horder.getId().getHEmail()}&handle=1Status'">交费</a>
								&nbsp;
									<a
									href="javascript:if(confirm('确定取消交费吗?'))location='<%=request.getContextPath()%>/HorderStatusServlet?temail=${horder.getId().getTEmail() }&hemail=${horder.getId().getHEmail()}&handle=0Status'">取消</a></td>
							</tr>

						</c:forEach>
						<c:forEach var="rorder" items="${tourist.getRorders()}"
							varStatus="status">
							<c:choose>
								<c:when test="${rorder.status=='0'}">
									<c:set value="未交费" var="fg2" />

								</c:when>
								<c:otherwise>
									<c:set value="交费" var="fg2" />

								</c:otherwise>
							</c:choose>
							<tr>
								<td>${status.index +1}</td>
								<td>${rorder.getRoute().rcname }</td>
								<td>${rorder.getRoute().money }</td>
								<td>${fg2 }</td>
								
								<td><a
									href="javascript:if(confirm('确定要交费吗?'))location='<%=request.getContextPath()%>/RorderStatusServlet?temail=${rorder.getId().getTEmail() }&rname=${rorder.getId().getRName()}&handle=1Status'">交费</a>
								&nbsp;
									<a
									href="javascript:if(confirm('确定取消交费吗?'))location='<%=request.getContextPath()%>/RorderStatusServlet?temail=${rorder.getId().getTEmail() }&rname=${rorder.getId().getRName()}&handle=0Status'">取消</a></td>
							</tr>

						</c:forEach>
					</tbody>
				</table>
				<br>
				<br>
			</c:forEach>


		</div>
		<!--// end row -->
	</div>
</div>
</div>
<!-- End Latest Products -->

<jsp:include page="Footer.jsp" flush="true"></jsp:include>
<%
	String flag = "";
	String scerror = "";
	flag = (String) request.getAttribute("flag");
	System.out.println("jspflag" + flag);
	if (flag != null) {
		if (flag.equals("1")) {
			scerror = "交费成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("0")) {
			scerror = "取消交费。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("3")) {
			scerror = "添加成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("2")) {
			scerror = "添加失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}


	}
	System.out.println(scerror);
%>
<!-- Back To Top -->
<a href="javascript:void(0);" class="js-back-to-top back-to-top">Top</a>

<!-- JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- CORE PLUGINS -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<script src="vendor/jquery-migrate.min.js" type="text/javascript"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
</body>
<!-- END BODY -->
</html>